﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data.Linq;
using System.Data.SqlClient;
using Website.Logger;
using UtilityExtensions;
using System.Web.Script.Services;
using System.Web.Services;
using BOL;

namespace UILGestion.Admin.Cliente
{
    public partial class ClienteListForm : System.Web.UI.Page
    {

     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {

                    
                    menuCtrl1.loadMenuAdmin();
                    FormatForm();


                }
                catch (SqlException sqlex)
                {
                    WebServerSideSqlError.Log(sqlex);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                     "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


                }
                catch (Exception ex)
                {
                    WebServerSideError.Log(ex);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                     "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

                }


            }
        }

        //private void Find()
        //{
        //    dbGestionDataContext _db;

        //    _db = new dbGestionDataContext(Parametros.strConnString);

        //    //(DD/MM/yyyy)
        //    System.IFormatProvider MiFp =
        //                                                new System.Globalization.
        //                                                CultureInfo("es-ES", false);
        //    //valores de parametro

        //    int selectid =  int.Parse(idObra.Value);

        //    //valores de parametro

        //    DateTime fechaInicio = new DateTime(2010, 1, 1);
        //    DateTime fechafin = DateTime.Now;

        //    //para los anulados
        //    bool anula = false;
        //    anula=!(anulaCheckBox.Checked);

        //    if (inicioDateTime.Text.Length > 0)
        //    {
        //        fechaInicio =
        //            System.DateTime.ParseExact(inicioDateTime.Text, "dd/MM/yyyy", MiFp);
        //    }
        //    if (finDateTime.Text.Length > 0)
        //    {
        //        fechafin =
        //            System.DateTime.ParseExact(finDateTime.Text, "dd/MM/yyyy", MiFp);
        //    }


        //    IQueryable<view_OrdenCompra> q;
        //    BOL.OrdenCompraBL bol = new BOL.OrdenCompraBL();


        //    entityListGridView.DataSource = bol.getOrdenCompraList(selectid,fechaInicio,fechafin);
        //    entityListGridView.DataBind();


        //}

        private void FormatForm()
        {
           
            ShowAllComboBox();


        }
        protected void ShowAllComboBox()
        {
            estadoDDL.DataSource = new BOL.ListValueBL().GetEstadoCliente();
            estadoDDL.DataBind();
        }


        protected void button(object sender, EventArgs e)
        {
            try
            {
                Response.Redirect("ClienteEditForm.aspx?type=A", true);
            }
            catch (SqlException sqlex)
            {
                WebServerSideSqlError.Log(sqlex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


            }
            catch (Exception ex)
            {
                WebServerSideError.Log(ex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

            }
             
        }
       
    }
}